
/**
 * Created by xiongshilin on 2017/4/14.
 */
ADF.domControl.BootstrapRow = function(parent) {
    ADF.domControl.BootstrapRow.superclass.constructor.call(this, parent);
    this.feedbackDom = null;
};

COM.util.defineClass(ADF.domControl.BootstrapRow, ADF.domControl.Composite, {
    setHeight: function(height) {
        COM.util.HTMLUtil.setElementMinHeight(this.domElement, height);
    },
    getLabel: function(){
        return "Row";
    },
    appendDomChild: function(child) {
        this.getDomElement().children[0].appendChild(child);
    },
    removeDomChild: function(child) {
        this.getDomElement().children[0].removeChild(child);
    },
    _getDomElement: function(model) {
        var rowWrap = this.createRowWrap(model);
        var row = this.createRow(model);
        rowWrap.append(row);
        this.domElement = rowWrap[0];
        return this.domElement;
    },
    createRowWrap: function(model) {
        var height = model.getLayoutData();
        var rowWrap = COM.util.HTMLUtil.createELement('<div class="bootstrapWrap rowWrap adf_wrapper"></div>');
        var css = {"display":"block",
            "position":"relative"
        };
        css.minHeight = height > 0 ? height:30;
        rowWrap.css(css);
        return rowWrap;
    },
    createRow: function(model) {
        var row = COM.util.HTMLUtil.createELement('<div class="row"></div>');
        var css = {"position":"relative",
            "overflow":"visible"
            /*"background-color":"rgba(89,89,89,1)"*/};
        //css.minHeight = 60;
        row.css(css);
        return row;
    },
    showFeedback: function(model) {
        var bounds = model.getBounds(), css = {};
        if(this.feedbackDom == null) {
            var feedBackCol = COM.util.HTMLUtil.createELement('<div class="'+model.getLayoutData()+'"></div>');
            css = {"position":"relative", "overflow":"visible", "background":"none", "border":"1px dashed #808080"};
            feedBackCol.css(css);
            this.feedbackDom = feedBackCol[0];
        } else {
            $(this.feedbackDom).attr('class', model.getLayoutData());
        }
        if(bounds.height >= 0) {
            this.feedbackDom.style.height = bounds.height + "px";
        }
        this.domElement.children[0].appendChild(this.feedbackDom);
    },
    eraseFeedback: function() {
        if(COM.util.HTMLUtil.hasChild(this.domElement, this.feedbackDom)) {
            this.domElement.children[0].removeChild(this.feedbackDom);
        }
    }
});